﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace FilterData
{
    public class FilterSize : IFilterData
    {
        public byte[] ProcessDataSend(byte[] data)
        {
            int length = data.Length;
            byte[] sizeSend = BitConverter.GetBytes((Int16)length);
            byte[] ArraySend = new byte[length + 2];
            //ArraySend[0] = (byte)length;
            Buffer.BlockCopy(sizeSend, 0, ArraySend, 0, sizeSend.Length);
            Buffer.BlockCopy(data, 0, ArraySend, 2, length);
            return ArraySend;
        }
        public byte[] ProcessDataReceive(byte[] data)
        {
            //int length = data[0];
            List<byte> tmp = new List<byte>() {data[0],data[1]};
            Int16 length = BitConverter.ToInt16(tmp.ToArray(), 0);
            byte[] ArrayReceive = new byte[length];
            Buffer.BlockCopy(data, 2, ArrayReceive, 0, length);
            return ArrayReceive;
        }
    }
}